<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	$merchid=intval($_RQ['merchid']);
	if($this->setting['zc_merch']){
		$merchid=model('jy_merch/model')->checkmerch($merchid);
	}else{
		$merchid=model('jy_merch/model')->checkadd_merch('','',$merchid);
	}
	$return['params']=array('merchid'=>$merchid,'status'=>10);
	$params=array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid,'ispay'=>1);
	$return['ordernum']=pdo_count('jy_merch_game_order',$params);
	$return['orderfee']=pdo_getsum('jy_merch_game_order',$params,'fee');
	$return['post']=array('id'=>0);
	if(!$merchid){
		exi('请选择商户！','error');
	}
	set_html('title','商户后台');
	exi($return);
}
// js 获取数据
if($_RQ['op']=='getlist'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'merchid'=>intval($_RQ['merchid']),'ispay'=>1);
	$return['params']['merchid']=intval($_RQ['merchid']);
	if(isset($_RQ['status']) && intval($_RQ['status'])!=10){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=intval($_RQ['status']);
	}else{
		$return['params']['status']=10;
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$list=pdo_getslice('jy_merch_game_order',$params,array($pindex,$psize),$total,$fields,'','createtime desc');
	if($list){
		$allitemgame=$this->allitemgame;
		foreach($list as &$item){
			$item['member']=cfc('core')->member_show($item['mid']);
			$item['info']=pdo_get('jy_merch_game_item',array('id'=>$item['pid'],'uniacid'=>$_SESSION['uniacid']),array('title'));
			$item['merch']=pdo_get('jy_merch_user',array('id'=>$item['merchid'],'uniacid'=>$_SESSION['uniacid']),array('id','merchname','logo','pcd','address'));
			$item['merch']['pcd']=json_decode($item['merch']['pcd'],true);
			$item['sendtypetitle']=$this->sendtypes[$item['sendtype']];
			$item['statustitle']=$this->order_status[$item['status']];
			$item['goods']=json_decode($item['goods'],true);
			$item['address']=json_decode($item['address'],true);
			$item['typetitle']=$allitemgame[$item['gamename']]['title'];
			$item['createtime']=date('Y-m-d H:i:s', $item['createtime']);
			if($item['tihuo_id']){
				$item['tihuo']=pdo_get('jy_merch_tihuo',array('id'=>$item['tihuo_id'],'uniacid'=>$_SESSION['uniacid']));
			}else{
				$item['tihuo']=pdo_get('jy_merch_tihuo',array('merchid'=>$item['merchid'],'uniacid'=>$_SESSION['uniacid']));
			}
			$item['tihuo']['pcd']=json_decode($item['tihuo']['pcd'],true);
		}
	}
	$return['list']=$list;
	exi($return);
}